<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [1, 2, 5, 4, 6, 7, 9, 11];
        let a = 0;
        function suoYin(num, arr) {
            for (i = 0; i < arr.length; i++) {
                if (num == arr[i]) {
                    a = i;
                    break;
                } else {
                    a = -1;
                }
            }
            return a;
        }
        let num = +prompt("请输入你要搜索的数字");
        document.write(suoYin(num, arr));
    </script>
</body>

</html>